﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Pay.Data;
using Pay.DTO;
using Pay.DTO.htl;
using Pay.TO;
using System.Data;

namespace Pay.IService {
    public interface IOrderService {
        /// <summary>
        /// 订单查询
        /// </summary>
        /// <param name="orderQuery"></param>
        /// <returns></returns>
        PagedResult<order_dto> Get(OrderQuery orderQuery);
        /// <summary>
        /// 查询订单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        order_dto Get(long id);
        /// <summary>
        /// 查询订单
        /// </summary>
        /// <param name="orderQuery"></param>
        /// <returns></returns>
        List<Pay.Data.Order> Gets(OrderQuery orderQuery);
        /// <summary>
        /// 根据PayInfoId查询
        /// </summary>
        /// <param name="PayId"></param>
        /// <returns></returns>
        List<order_dto> GetListByPayId(long PayId);
        /// <summary>
        /// 根据订单号查询所有订单【多单情况】
        /// </summary>
        /// <param name="orderNo"></param>
        /// <returns></returns>
        List<order_dto> GetOrdersByOrderNo(string orderNo);
        /// <summary>
        /// 分账
        /// </summary>
        /// <param name="charge"></param>
        /// <param name="ord_htmls"></param>
        void OverSeasMallAccounts(charge_dto charge, List<order_dto> ord_htmls);
        /// <summary>
        /// 查询订单
        /// </summary>
        /// <param name="order_no"></param>
        /// <returns></returns>
        order_dto Get(string order_no);
        int PaySuceess(pay_html_dto payHtml, string transaction_no, DateTime? pay_time);
        Charge MallPaySuccess(pay_html_dto payHtml, string transaction_no, DateTime? pay_time);

        int CloseOrder(long order_id);
        int Add(order_dto dto);
        /// <summary>
        /// 自动关闭过期没付款的订单
        /// </summary>
        /// <returns></returns>
        List<order_dto> CloseOrder();
        /// <summary>
        /// 自动收货定时任务
        /// </summary>
        /// <returns></returns>
        Task<int> AutoOrderFinish();
        /// <summary>
        /// 自动结算账单
        /// </summary>
        /// <param name="merchant_id"></param>
        void AutoSettleAccount(long merchant_id = 0);
        /// <summary>
        /// 订单发货
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ApiResultMessage OrderDelivery(order_model dto);
        /// <summary>
        /// 确认收货
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ApiResultMessage OrderReceipt(order_model dto);
        /// <summary>
        /// 向海关推送支付单
        /// </summary>
        /// <returns>The push.</returns>
        /// <param name="model">Model.</param>
        sxy_customs_result_base CustomsPush(sxy_customs_push model);
        /// <summary>
        /// 向海关支付单查询
        /// </summary>
        /// <returns>The query.</returns>
        /// <param name="model">Model.</param>
        sxy_customs_result_base CustomsQuery(sxy_customs_query model);
        /// <summary>
        /// 生成订单xml文件
        /// </summary>
        /// <param name="pay_id">Pay identifier.</param>
        string CreateOrderXml(long pay_id);
        /// <summary>
        /// 向海关推送订单xml文件
        /// </summary>
        /// <returns><c>true</c>, if order xml was pushed, <c>false</c> otherwise.</returns>
        /// <param name="path">Path.</param>
        bool PushOrderXml(string path);

        /// <summary>
        /// 修改订单状态
        /// </summary>
        /// <param name="id">payinfoid</param>
        /// <param name="orderStatus">状态</param>
        /// <returns></returns>
        int Update(long id, OrderStatus orderStatus, string transaction_no);
        int UpdateOrderItem(long id, List<order_item_dto> list);
        int Delete(long Id);
        /// <summary>
        /// 跨境电商发货
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int OrderDelivery(long id);
        /// <summary>
        /// 订单发货
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        int OrderDelivery(order_dto_ex dto);

        /// <summary>
        /// 创建待支付订单
        /// </summary>
        /// <returns>The pay order.</returns>
        /// <param name="payHtml">Pay html.</param>
        int WaitPayOrder(pay_html_dto payHtml);
        /// <summary>
        /// 创建多单待支付订单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        int WaitPayOrder(mall_model model);
        /// <summary>
        /// h5支付成功
        /// </summary>
        /// <returns>The h5 success.</returns>
        /// <param name="payHtml">Pay html.</param>
        /// <param name="transaction_no">Transaction no.</param>
        /// <param name="pay_time">Pay time.</param>
        int PayH5Success(pay_html_dto payHtml, string transaction_no, DateTime? pay_time);
        /// <summary>
        /// 确认订单
        /// </summary>
        /// <returns>The out.</returns>
        /// <param name="model">Model.</param>
        /// <param name="isSeaOver">If set to <c>true</c> is sea over.</param>
        List<order_dto> CheckOut(CartModel model, out bool isSeaOver);
        /// <summary>
        /// 获取支付订单
        /// </summary>
        /// <returns>The out pay.</returns>
        /// <param name="model">Model.</param>
        /// <param name="object_id">Object identifier.</param>
        mall_model CheckOutPay(CartPayModel model, out object object_id);
        List<order_dto> GetOrderList(object object_id);
        void SetOrderList(List<order_dto> list, object object_id);
        void ClearOrderList(object object_id);
        void SetOrderModelCache(token_mall_confirm_order_model model, string key);
        token_mall_confirm_order_model GetOrderModelCache(string key);
        void ClearOrderModelCache(string key);
        /// <summary>
        /// 获取拓垦商城支付订单---->多单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        mall_model GetTokenMallPayOrder(token_check_out_model model);
        /// <summary>
        /// 删除拓垦商城商品订单
        /// </summary>
        /// <param name="id"></param>
        int DeleteOrder(long id);
        /// <summary>
        /// 确认收货拓垦商城商品订单
        /// </summary>
        /// <param name="id"></param>
        int ConfirmOrder(long id);
        /// <summary>
        /// 后台手工确认收货
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int HandConfirmOrder(long id);
        /// <summary>
        /// 更新订单状态
        /// </summary>
        /// <param name="res"></param>
        string UpdateShipping(htl_orders_info_res res);
        /// <summary>
        /// 订单退款/退货
        /// </summary>
        /// <param name="order_refund"></param>
        /// <returns></returns>
        int OrderRefund(order_refund_dto order_refund);
        /// <summary>
        /// 立即购买 购物车购买
        /// </summary>
        /// <param name="cartModel"></param>
        /// <param name="type">0 立即购买 1 购物车</param>
        /// <returns></returns>
        token_check_out_model AddBuy(List<AddCartModel> cartModel, int type);

        #region 获取拓垦商城
        /// <summary>
        /// 获取商城首页统计
        /// </summary>
        /// <param name="user_id"></param>
        /// <returns></returns>
        token_merchant_order_count GetOrderCount(long user_id);
        /// <summary>
        /// 修改待支付订单
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        int ModifyWaitOrder(spc_modify_wait_pay_order_model dto);
        #endregion
        /// 修改订单收货地址信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        int OrderShiping(shipping_address_dto dto);
        /// <summary>
        /// 修改订单号
        /// </summary>
        /// <param name="order_no"></param>
        /// <returns></returns>
        int SaveOrderNo(string order_no, string new_order_no);
        /// <summary>
        /// 停止自动推单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int StopAutoOrder(long id);

        /// <summary>
        /// 导入发货信息
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        bool ImportDelivery(DataTable dt);
        void AutoSettleAccount(string orderNo);
        /// <summary>
        /// 实人认证支付订单
        /// </summary>
        /// <param name="merchantId"></param>
        /// <param name="ip"></param>
        /// <returns></returns>
        mall_model GetFaceMall(long merchantId, string ip);
    }
}
